require 'rexml/document'
require "testcase"
include REXML

module LWA
    class TestCaseDoc

        attr_reader :property

        def initialize(file_name)
            @case_doc = Document.new(File.new(File.join(File.dirname(__FILE__), '..', 'TestCase', file_name)))
        end

        def get_case(case_number)
            tc = Testcase.new XPath.first(@case_doc, "//Case[@id=#{case_number}]")
            if tc == nil then
                raise "ERROR: Can't get test case as number #{case_number}"
            end
            return tc
        end

        def get_resource(res_name)
            XPath.first(@case_doc, "//Item[@name='#{res_name}']").attributes["value"]
        end
        
    end
end